package com.xk.sport.backend.dao.repository;

import com.xk.sport.backend.dao.model.TeacherLesson;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TeacherLessonDao extends JpaRepository<TeacherLesson, Long>, JpaSpecificationExecutor<TeacherLesson> {

    @Query(value = "select * from teacher_lesson where teacherId in (?1)", nativeQuery = true)
    List<TeacherLesson> findTeacherLessonsByTeacherIds(List<Long> teacherIds);

    @Transactional
    @Modifying
    @Query(value = "delete from teacher_lesson where teacherId = ?", nativeQuery = true)
    void deleteTeacherLessonsByTeacherId(long teacherId);
}
